package com.gklee.regionselector;

import java.util.ArrayList;

public class SelectBean
{
    private int index = 0;
    private int id = 0;
    private String name;
    private SelectBean parentBean = null;
    private ArrayList<SelectBean> childBeans = null;
    private PVGSuppliesBean suppliesBean = null;

    public PVGSuppliesBean getSuppliesBean()
    {
        return suppliesBean;
    }

    public void setSuppliesBean(PVGSuppliesBean suppliesBean)
    {
        this.suppliesBean = suppliesBean;
    }

    public SelectBean()
    {
    }

    public int getId()
    {
        return id;
    }

    public void setId(int id)
    {
        this.id = id;
    }

    /**
     * 获取名字
     * @return
     */
    public String getName()
    {
        return name;
    }

    /**
     * 设置名字
     * @param name
     */
    public void setName(String name)
    {
        this.name = name;
    }

    /**
     * 获取父亲bean
     * @return
     */
    public SelectBean getParentBean()
    {
        return parentBean;
    }

    /**
     * 设置父类bean
     * @param parentBean
     */
    public void setParentBean(SelectBean parentBean)
    {
        this.parentBean = parentBean;
    }

    /**
     * 获取当前的索引
     * @return
     */
    public int getIndex()
    {
        return index;
    }

    /**
     * 设置当前的索引
     * @param index
     */
    public void setIndex(int index)
    {
        this.index = index;
    }

    /**
     * 获取子节点
     * @return
     */
    public ArrayList<SelectBean> getChildBeans()
    {
        return childBeans;
    }

    /**
     * 设置子节点
     * @param childBeans
     */
    public void setChildBeans(ArrayList<SelectBean> childBeans)
    {
        this.childBeans = childBeans;
    }

    /**
     * 添加子元素
     * @param name 子元素的名字
     */
    public SelectBean addChild(String name, int id)
    {
        if(getChildBeans() == null)
        {
            setChildBeans(new ArrayList<SelectBean>());
        }
        SelectBean bean = new SelectBean();
        bean.name = name;
        bean.parentBean = this;
        bean.index = getChildBeans().size();
        bean.id = id;
        getChildBeans().add(bean);
        return bean;
    }

    /**
     * 是否有子元素
     * @return
     */
    public boolean hasChild()
    {
        return getChildBeans() != null && getChildBeans().size() != 0;
    }

    @Override
    public String toString()
    {
        return "SelectBean{" +
                "id=" + id +
                ", name='" + name + '\'' +
                '}';
    }
}
